package com.common.msg.service;

import com.common.msg.entity.SysMessageBo;
import com.see.utils.SseMessageUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SendMessageService {
    private static final Logger log = LoggerFactory.getLogger(SendMessageService.class);
    @Autowired
    SysMessageService sysMessageService;
    //群发申报消息
    public   void batchSendMessageDeclare(String title,String  enddate){
        try {
            String message="申报计划：%s 已经开始申报了，截止日期是：%s";
            message=  String.format(message, title,enddate);
            SysMessageBo sysMessageBo = new SysMessageBo();
            sysMessageBo.setContent(message);
            sysMessageBo.setIsRead("0");
            sysMessageBo.setTitle("申报通知");
            sysMessageBo.setRevicerId("all");
            sysMessageService.insertSysMessage(sysMessageBo);
            SseMessageUtils.batchSendMessage(message);
        }
        catch (Exception e){
           // throw new IllegalArgumentException("申报通知错误:"+e.toString());
          log.error("申报通知错误:"+e.toString());
        }

    }
}
